local scene = director:createScene()

function scene:setUp(event)
    dbg.print("sceneScore:setUp")
	
	local scaleX = 320/director.displayWidth
	local scaleY = 480/director.displayHeight
	
	file = io.open("levelrecord.txt")
	levelListOne = file:read()
	levelListTwo = file:read()
	levelListThree = file:read()
	levelListFour = file:read()
	levelListFive = file:read()
	file:close()
	
	local xValue = director.displayCenterX
	local yValue = director.displayCenterY
	
	local box1 = director:createRectangle( {x=xValue, y=yValue, w=220/scaleX, h=380/scaleY, color=color.green, xAnchor=0.5, yAnchor=0.5,} )
	local labelScoreOne = director:createLabel({x=xValue, y=box1.y+box1.h/3, text="BEST LEVELS", hAlignment="center", xAnchor=0.5, color=color.black, xScale=1/scaleX, yScale=1/scaleY})
	local labelScoreTwo = director:createLabel({x=xValue, y=box1.y+box1.h/8, text="1--  "..levelListOne, hAlignment="center", xAnchor=0.5, color=color.black, xScale=1/scaleX, yScale=1/scaleY})
	local labelScoreThree = director:createLabel({x=xValue, y=box1.y, text="2--  "..levelListTwo, hAlignment="center", xAnchor=0.5, color=color.black, xScale=1/scaleX, yScale=1/scaleY})
	local labelScoreFour = director:createLabel({x=xValue, y=box1.y-box1.h/8, text="3--  "..levelListThree, hAlignment="center", xAnchor=0.5, color=color.black, xScale=1/scaleX, yScale=1/scaleY})
	local labelScoreFive = director:createLabel({x=xValue, y=box1.y-box1.h/4, text="4--  "..levelListFour, hAlignment="center", xAnchor=0.5, color=color.black, xScale=1/scaleX, yScale=1/scaleY})
	local labelScoreSix = director:createLabel({x=xValue, y=box1.y-box1.h*3/8, text="5--  "..levelListFive, hAlignment="center", xAnchor=0.5, color=color.black, xScale=1/scaleX, yScale=1/scaleY})

	local buttonBack = director:createSprite(250/scaleX, 50/scaleY, "img/button.png")
	buttonBack.xAnchor=0.5; buttonBack.yAnchor=0.5
	buttonBack.xScale=.5/scaleX; buttonBack.yScale=.5/scaleY; 
	buttonBack.y = buttonBack.y - buttonBack.h/2.5/scaleY
	labelBack = director:createLabel(250/scaleX, 0, "Back")
	labelBack.xAnchor=0.5;
	labelBack.zOrder = buttonBack.zOrder
	labelBack. hAlignment="center"
	labelBack.xScale=1/scaleX
	labelBack.yScale=1/scaleY
	
	function buttonBack:touch(event)
		if (event.phase == 'began') then
			system:sendEvent("moveToSceneMenu")
		end
	end
	buttonBack:addEventListener('touch', buttonBack)

end

function scene:tearDown(event)
    dbg.print("sceneScore:tearDown")
end

scene:addEventListener({"setUp", "tearDown"}, scene)

return scene -- We must return the scene object!